home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / DeskBus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  8.2 KB  |  212 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        DeskBus.h
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1987-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __DESKBUS__
  19. #define __DESKBUS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. #if TARGET_OS_MAC
  51. typedef SInt8                             ADBAddress;
  52. typedef CALLBACK_API( void , ADBCompletionProcPtr )(Ptr buffer, Ptr refCon, long command);
  53. /*
  54.     WARNING: ADBCompletionProcPtr uses register based parameters under classic 68k
  55.              and cannot be written in a high-level language without 
  56.              the help of mixed mode or assembly glue.
  57. */
  58. typedef CALLBACK_API( void , ADBDeviceDriverProcPtr )(SInt8 devAddress, SInt8 devType);
  59. /*
  60.     WARNING: ADBDeviceDriverProcPtr uses register based parameters under classic 68k
  61.              and cannot be written in a high-level language without 
  62.              the help of mixed mode or assembly glue.
  63. */
  64. /*
  65.     TempADBServiceRoutineUPP is needed because of circular definition of
  66.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  67. */
  68. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             TempADBServiceRoutineUPP;
  69. typedef CALLBACK_API( void , ADBServiceRoutineProcPtr )(Ptr buffer, TempADBServiceRoutineUPP completionProc, Ptr refCon, long command);
  70. /*
  71.     WARNING: ADBServiceRoutineProcPtr uses register based parameters under classic 68k
  72.              and cannot be written in a high-level language without 
  73.              the help of mixed mode or assembly glue.
  74. */
  75. typedef REGISTER_UPP_TYPE(ADBCompletionProcPtr)                 ADBCompletionUPP;
  76. typedef REGISTER_UPP_TYPE(ADBDeviceDriverProcPtr)                 ADBDeviceDriverUPP;
  77. typedef REGISTER_UPP_TYPE(ADBServiceRoutineProcPtr)             ADBServiceRoutineUPP;
  78. /*
  79.     typedef pascal void (*ADBInitProcPtr)(SInt8 callOrder);
  80.  
  81.     Note: ADBInitProcPtr can only be created in 68K assembly language 
  82.           since it is a head patch that must JUMP to the previous address
  83. */
  84.  
  85. struct ADBDataBlock {
  86.     SInt8                             devType;                    /* original handler ID */
  87.     SInt8                             origADBAddr;                /* original ADB Address */
  88.     ADBServiceRoutineUPP             dbServiceRtPtr;                /* service routine pointer */
  89.     Ptr                             dbDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  90. };
  91. typedef struct ADBDataBlock                ADBDataBlock;
  92.  
  93. typedef ADBDataBlock *                    ADBDBlkPtr;
  94.  
  95. struct ADBSetInfoBlock {
  96.     ADBServiceRoutineUPP             siService;                    /* service routine pointer */
  97.     Ptr                             siDataAreaAddr;                /* this field is passed as the refCon parameter to the service routine */
  98. };
  99. typedef struct ADBSetInfoBlock            ADBSetInfoBlock;
  100.  
  101. typedef ADBSetInfoBlock *                ADBSInfoPtr;
  102. /* ADBOpBlock is only used when calling ADBOp from 68k assembly code */
  103.  
  104. struct ADBOpBlock {
  105.     Ptr                             dataBuffPtr;                /* buffer: pointer to variable length data buffer */
  106.     ADBServiceRoutineUPP             opServiceRtPtr;                /* completionProc: completion routine pointer */
  107.     Ptr                             opDataAreaPtr;                /* refCon: this field is passed as the refCon parameter to the completion routine */
  108. };
  109. typedef struct ADBOpBlock                ADBOpBlock;
  110.  
  111. typedef ADBOpBlock *                    ADBOpBPtr;
  112. EXTERN_API( void )
  113. ADBReInit                        (void)                                                        ONEWORDINLINE(0xA07B);
  114.  
  115. /*
  116.     ADBOp has a different interface for 68k assembly than for everything else
  117.     for 68k assembly the interface is 
  118.     #pragma parameter __D0 ADBOp(__A0,__D0)
  119.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  120. */
  121. /*
  122.     IMPORTANT NOTE:
  123.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  124.     four parameters using 68k register based calling conventions, specifically the completion routine
  125.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  126.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  127.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  128.     the mistake cannot be corrected.
  129.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  130.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  131.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  132.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  133. */
  134. EXTERN_API( OSErr )
  135. ADBOp                            (Ptr                     refCon,
  136.                                  ADBCompletionUPP         compRout,
  137.                                  Ptr                     buffer,
  138.                                  short                     commandNum);
  139.  
  140.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  141.                                                                                             #pragma parameter __D0 CountADBs
  142.                                                                                             #endif
  143. EXTERN_API( short )
  144. CountADBs                        (void)                                                        ONEWORDINLINE(0xA077);
  145.  
  146.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  147.                                                                                             #pragma parameter __D0 GetIndADB(__A0, __D0)
  148.                                                                                             #endif
  149. EXTERN_API( ADBAddress )
  150. GetIndADB                        (ADBDataBlock *            info,
  151.                                  short                     devTableIndex)                        ONEWORDINLINE(0xA078);
  152.  
  153.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  154.                                                                                             #pragma parameter __D0 GetADBInfo(__A0, __D0)
  155.                                                                                             #endif
  156. EXTERN_API( OSErr )
  157. GetADBInfo                        (ADBDataBlock *            info,
  158.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA079);
  159.  
  160.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  161.                                                                                             #pragma parameter __D0 SetADBInfo(__A0, __D0)
  162.                                                                                             #endif
  163. EXTERN_API( OSErr )
  164. SetADBInfo                        (const ADBSetInfoBlock * info,
  165.                                  ADBAddress             adbAddr)                            ONEWORDINLINE(0xA07A);
  166.  
  167. enum { uppADBCompletionProcInfo = 0x007B9802 };                 /* register no_return_value Func(4_bytes:A0, 4_bytes:A2, 4_bytes:D0) */
  168. enum { uppADBDeviceDriverProcInfo = 0x00050802 };                 /* register no_return_value Func(1_byte:D0, 1_byte:D1) */
  169. enum { uppADBServiceRoutineProcInfo = 0x0F779802 };             /* register no_return_value Func(4_bytes:A0, 4_bytes:A1, 4_bytes:A2, 4_bytes:D0) */
  170. #define NewADBCompletionProc(userRoutine)                         (ADBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBCompletionProcInfo, GetCurrentArchitecture())
  171. #define NewADBDeviceDriverProc(userRoutine)                     (ADBDeviceDriverUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBDeviceDriverProcInfo, GetCurrentArchitecture())
  172. #define NewADBServiceRoutineProc(userRoutine)                     (ADBServiceRoutineUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADBServiceRoutineProcInfo, GetCurrentArchitecture())
  173. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  174.     /* CallADBCompletionProc can't be called from classic 68k without glue code */
  175. #else
  176.     #define CallADBCompletionProc(userRoutine, buffer, refCon, command)  CALL_THREE_PARAMETER_UPP((userRoutine), uppADBCompletionProcInfo, (buffer), (refCon), (command))
  177. #endif
  178. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  179.     #pragma parameter CallADBDeviceDriverProc(__A0, __D0, __D1)
  180.     void CallADBDeviceDriverProc(ADBDeviceDriverUPP routine, SInt8 devAddress, SInt8 devType) = 0x4E90;
  181. #else
  182.     #define CallADBDeviceDriverProc(userRoutine, devAddress, devType)  CALL_TWO_PARAMETER_UPP((userRoutine), uppADBDeviceDriverProcInfo, (devAddress), (devType))
  183. #endif
  184. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  185.     /* CallADBServiceRoutineProc can't be called from classic 68k without glue code */
  186. #else
  187.     #define CallADBServiceRoutineProc(userRoutine, buffer, completionProc, refCon, command)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppADBServiceRoutineProcInfo, (buffer), (completionProc), (refCon), (command))
  188. #endif
  189. #endif  /* TARGET_OS_MAC */
  190.  
  191.  
  192. #if PRAGMA_STRUCT_ALIGN
  193.     #pragma options align=reset
  194. #elif PRAGMA_STRUCT_PACKPUSH
  195.     #pragma pack(pop)
  196. #elif PRAGMA_STRUCT_PACK
  197.     #pragma pack()
  198. #endif
  199.  
  200. #ifdef PRAGMA_IMPORT_OFF
  201. #pragma import off
  202. #elif PRAGMA_IMPORT
  203. #pragma import reset
  204. #endif
  205.  
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209.  
  210. #endif /* __DESKBUS__ */
  211.  
  212.